package com.ktwlsoft.archivemanage.controller.dataProfile;

import com.ktwlsoft.archivemanage.domain.business.repositoryService.view.ProfileArchiveUnitRepositoryService;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "室藏档案分析")
@RestController
@RequestMapping("/archiveUnitProfile")
public class ArchiveUnitProfileController {

    private final ProfileArchiveUnitRepositoryService profileArchiveUnitRepositoryService;

    public ArchiveUnitProfileController(ProfileArchiveUnitRepositoryService profileArchiveUnitRepositoryService) {
        this.profileArchiveUnitRepositoryService = profileArchiveUnitRepositoryService;
    }

    @ApiOperation("立档单位室藏档案年度总量变化趋势")
    @GetMapping("/getAllVariation")
    public ResponseEntity<?> getAllVariation() {
        return ResponseEntity.ok(Result.ok(profileArchiveUnitRepositoryService.getProfileArchiveUnitTotalVariationMapper().selectAll()));
    }

    @ApiOperation("立档单位室藏档案年度总量变化趋势")
    @GetMapping("/getAllVariationByUnit")
    public ResponseEntity<?> getAllVariationByUnit(@ApiParam("单位Id") @RequestParam Long unitId) {
        return ResponseEntity.ok(Result.ok(
                profileArchiveUnitRepositoryService.getProfileArchiveUnitTypeVariationMapper().selectAll(unitId)));
    }
}
